<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>JPetStore</title>
    <link rel="stylesheet" href="../css/jpetstore.css" type="text/css"/>
    <link rel="stylesheet" href="../css/jquery-ui.css" type="text/css"/>
    <script th:src = "@{/JS/jquery-3.2.1.js}"></script>
    <script th:src = "@{/JS/jquery-ui.js}"></script>
</head>
<body>

    <div th:replace="/common/header.html"></div>

    <div id="Content">
        <div id="BackLink">
            <a th:href="@{'viewCategory?categoryId='+${product.getCategoryId()}}" th:text="'Return to '+${product.getCategoryId()}"></a>
        </div>

        <div id="Catalog">

            <h2 th:text="${product.getName()}"></h2>

            <table>
                <tr>
                    <th>Item ID</th>
                    <th>Product ID</th>
                    <th>Description</th>
                    <th>List Price</th>
                    <th>&nbsp;</th>
                </tr>

                <tr th:each="item:${itemList}">

                    <td><a th:href="@{'/catalog/viewItem?itemId='+${item.getItemId()}}" th:text="${item.getItemId()}"></a></td>

                    <td th:text="${item.getProductId()}"></td>

                    <td th:text="${item.getAttribute1()+item.getAttribute2+
                                   item.getAttribute3()+item.getAttribute4()+item.getAttribute5()+
                                   product.getName()}">
                    </td>

                    <td th:text="'$'+${#numbers.formatDecimal(item.getListPrice(),1,'COMMA',2,'POINT')}"></td>

                    <td th:if="${session.loginAccount ne null && item.getSupplierId() > 0  && item.getStatus() eq 'P'}">
                        <a class="Button" th:href="@{'/cart/addItemToCart?workingItemId='+${item.getItemId()}}">Add to Cart</a>
                    </td>

                    <td th:if="${session.loginAccount eq null && item.getSupplierId() > 0 && item.getStatus() eq 'P'}">
                        <a class="Button" th:href="@{/account/signOnForm}">Add to Cart</a>
                    </td>
                <td th:if="${item.getSupplierId() <= 0  || item.getStatus() eq 'NP'}">已经售完或者下架
                </td>

                </tr>
                <tr><td></td></tr>
            </table>

        </div>
    </div>

    <div th:replace="/common/footer.html"></div>

</body>
</html>